package com.financing.platform.dao.impl;

import java.sql.SQLException;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.financing.platform.dao.IFaUserAuthDao;
import com.financing.platform.dto.FaUserAuthDTO;
import com.financing.platform.dto.FaUserCertDTO;
import com.financing.platform.util.SqlName;

/**
 * 
* @ClassName: FaUserAuthDaoImpl 
* @Description: 查询Fa证书信息 
* @author chenming 
* @date 2014年8月28日 下午1:44:51 
*
 */
@Repository("faUserAuthDaoImpl")
public class FaUserAuthDaoImpl extends BaseDaoImpl implements IFaUserAuthDao {

	@SuppressWarnings("unchecked")
	public List<FaUserAuthDTO> queryFaUserAuthList(FaUserAuthDTO faUserAuthDTO) {
		try {
			return this.sqlMapClient.queryForList(SqlName.queryFaUserAuthByFaId, faUserAuthDTO);
		} catch (SQLException e) {
			log.error("Query fa user auth error :", e);
			return Collections.emptyList();
		}
	}
	
	
	@SuppressWarnings("unchecked")
	public List<FaUserCertDTO> queryFaUserCertList(FaUserCertDTO faUserCertDTO){
		try {
			return this.sqlMapClient.queryForList(SqlName.queryFaUserCertByFaId, faUserCertDTO);
		} catch (SQLException e) {
			log.error("Query fa user cert error :", e);
			return Collections.emptyList();
		}
	}


	public int updateFaUserAuth(FaUserAuthDTO faUserAuthDTO) throws SQLException {
		return this.sqlMapClient.update(SqlName.faUserAuthUpdate, faUserAuthDTO);
	}
	


	public int updateFaUserCert(FaUserCertDTO faUserCertDTO) throws SQLException {
		return this.sqlMapClient.update(SqlName.faUserCertUpdate, faUserCertDTO);
	}


	@Override
	public int addFaUserAuth(Map<String, Object> map) throws SQLException {

		return (Integer) this.sqlMapClient.insert(SqlName.faUserAuthAdd, map);
	}


	@Override
	public FaUserAuthDTO queryFaUserAuth(FaUserAuthDTO faUserAuthDTO)
			throws SQLException {
		return (FaUserAuthDTO) this.sqlMapClient.queryForObject(SqlName.faUserAuthQuery, faUserAuthDTO);
	}


	@Override
	public int updateFaUserAuthAll(Map<String, Object> map) throws SQLException {
		return this.sqlMapClient.update(SqlName.faUserAuthUpdateAll, map);
	}

}
